<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>icf</title>

	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport"
		content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" href="/public/layui/admin/layui/css/layui.css" media="all">
	<link rel="stylesheet" href="/public/layui/admin/style/admin.css" media="all">
</head>

<body>

	<div class="layui-fluid">
		<div class="layui-card">
			<div class="layui-card-header">订单明细</div>
			<div class="layui-card-body" style="padding: 15px;">
				<form class="layui-form" action="" lay-filter="component-form-group">
					{% if data.detail.Id %}
					<input name="id" type="hidden" value="{{ data.detail.Id }}" />
					{% endif %}

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">下单人名</label>
							<div class="layui-input-inline">
								<input type="text" id="user_name" name="user_name" value="{{ data.detail.UserName }}"
									lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
							</div>
						</div>

						<div class="layui-inline">
							<label class="layui-form-label">联系电话</label>
							<div class="layui-input-inline">
								<input type="text" id="mobile" name="mobile" value="{{ data.detail.Mobile }}"
									lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
							</div>
						</div>

						<div class="layui-inline">
							<label class="layui-form-label">订单类型</label>
							<div class="layui-input-block">
								{% if data.detail.OrderType == 2 %}
								<input type="text" id="order_type" name="order_type" value="快递" lay-verify="title"
									autocomplete="off" placeholder="" class="layui-input">
								{% else %}
								<input type="text" id="order_type" name="order_type" value="普通" lay-verify="title"
									autocomplete="off" placeholder="" class="layui-input">
								{% endif %}
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">省</label>
							<div class="layui-input-block">
								<input type="text" id="province" name="province" value="{{ data.detail.Province }}"
									lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">市</label>
							<div class="layui-input-block">
								<input type="text" id="city" name="city" value="{{ data.detail.City }}"
									lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">区</label>
							<div class="layui-input-block">
								<input type="text" id="area" name="area" value="{{ data.detail.Area }}"
									lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">收货地址</label>
						<div class="layui-input-block">
							<input type="text" id="address" name="address" value="{{ data.detail.Address }}"
								lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">


						
						{% if data.detail.IfFinish == 1 %}
						<label class="status">已完成</label>
						{% else %}
							{% if data.detail.IfCancel == 1 %}
							<label class="status">已取消</label>
							{% else %}
								{% if data.detail.IfRefund == 1 %}
								<label class="status">退款中</label>
								{% else %}
									{% if data.detail.IfDelivery == 1 %}
									<label class="status">已发货</label>
									{% else %}
										{% if data.detail.IfPay == 1 %}
										<label class="status">已支付</label>
										{% else %}
										<label class="status">未支付</label>
										{% endif %}
									{% endif %}
								{% endif %}
							{% endif %}
						{% endif %}

						

					</div>

					<div>
						<table class="layui-hide" id="data-table" lay-filter="data-table"></table>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">订单金额</label>
							<div class="layui-input-block">
								<input type="text" id="pro_amount" name="pro_amount"
									value="{{ data.detail.ProAmount/100.00 }}" lay-verify="title" autocomplete="off"
									placeholder="" class="layui-input">
							</div>
						</div>

						<div class="layui-inline">
							<label class="layui-form-label">应付金额</label>
							<div class="layui-input-block">
								<input type="text" id="payable_amount" name="payable_amount"
									value="{{ data.detail.PayableAmount/100.00 }}" lay-verify="title" autocomplete="off"
									placeholder="" class="layui-input">
							</div>
						</div>

						<div class="layui-inline">
							<label class="layui-form-label">实付金额</label>
							<div class="layui-input-block">
								<input type="text" id="real_amount" name="real_amount"
									value="{{ data.detail.RealAmount/100.00 }}" lay-verify="title" autocomplete="off"
									placeholder="" class="layui-input">
							</div>
						</div>

					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">余额抵扣</label>
							<div class="layui-input-block">
								<input type="text" id="balance_amout" name="balance_amout"
									value="{{ data.detail.BalanceAmout }}" lay-verify="title" autocomplete="off"
									placeholder="" class="layui-input">
							</div>
						</div>

						<div class="layui-inline">
							<label class="layui-form-label">邮费</label>
							<div class="layui-input-block">
								<input type="text" id="postage" name="postage" value="{{ data.detail.Postage }}"
									lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
							</div>
						</div>

						<div class="layui-inline">
							<label class="layui-form-label">优惠金额</label>
							<div class="layui-input-block">
								<input type="text" id="discount_fee" name="discount_fee"
									value="{{ data.detail.DiscountFee }}" lay-verify="title" autocomplete="off"
									placeholder="" class="layui-input">
							</div>
						</div>
					</div>
					{% if data.detail.IfPay == 1 %}
					<div class="layui-form-item">

						<div class="layui-inline">
							<label class="layui-form-label">付款时间</label>
							<div class="layui-input-block">
								<input type="text" id="pay_time" name="pay_time" value="{{ data.detail.PayTime }}"
									lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
							</div>
						</div>

						<div class="layui-inline">
							<label class="layui-form-label">支付交易号</label>
							<div class="layui-input-block">
								<input type="text" id="trade_no" name="trade_no" value="{{ data.detail.TradeNo }}"
									lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
							</div>
						</div>
					</div>

					{% endif %}

					{% if data.detail.IfCancel == 1 %}
					<div class="layui-form-item">
						<label class="layui-form-label">取消时间</label>
						<div class="layui-input-block">
							<input type="text" id="cancel_time" name="cancel_time" value="{{ data.detail.CancelTime }}"
								lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
						</div>
					</div>

					{% endif %}

					{% if data.detail.IfDelivery == 1 %}


					<div class="layui-form-item">

						<div class="layui-inline">

							<label class="layui-form-label">发货时间</label>
							<div class="layui-input-block">
								<input type="text" id="delivery_time" name="delivery_time"
									value="{{ data.detail.DeliveryTime }}" lay-verify="title" autocomplete="off"
									placeholder="" class="layui-input">
							</div>
						</div>

						<div class="layui-inline">
							<label class="layui-form-label">物流公司</label>
							<div class="layui-input-block">
								<input type="text" id="logistics_company" name="logistics_company"
									value="{{ data.detail.LogisticsCompany }}" lay-verify="title" autocomplete="off"
									placeholder="" class="layui-input">
							</div>
						</div>



						<div class="layui-inline">
							<label class="layui-form-label">物流单号</label>
							<div class="layui-input-block">
								<input type="text" id="logistics_no" name="logistics_no"
									value="{{ data.detail.LogisticsNo }}" lay-verify="title" autocomplete="off"
									placeholder="" class="layui-input">
							</div>
						</div>

					</div>


					{% endif %}





					<div class="layui-form-item">
						<label class="layui-form-label">备注</label>
						<div class="layui-input-block">
							<input type="text" id="remark" name="remark" value="{{ data.detail.Remark }}"
								lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
						</div>
					</div>



					<!-- <div class="layui-form-item">
						<label class="layui-form-label">付款状态</label>
						<div class="layui-input-block">
							<input type="text" id="if_pay" name="if_pay" value="{{ data.detail.IfPay }}"
								lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
						</div>
					</div> -->






					<!-- <div class="layui-form-item">
						<label class="layui-form-label">取消订单标志</label>
						<div class="layui-input-block">
							<input type="text" id="if_cancel" name="if_cancel" value="{{ data.detail.IfCancel }}"
								lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
						</div>
					</div> -->






					<!-- <div class="layui-form-item">
						<label class="layui-form-label">是否发货</label>
						<div class="layui-input-block">
							<input type="text" id="if_delivery" name="if_delivery" value="{{ data.detail.IfDelivery }}"
								lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
						</div>
					</div> -->






					<!-- <div class="layui-form-item">
						<label class="layui-form-label">是否完成</label>
						<div class="layui-input-block">
							<input type="text" id="if_finish" name="if_finish" value="{{ data.detail.IfFinish }}"
								lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
						</div>
					</div>



					<div class="layui-form-item">
						<label class="layui-form-label">是否申请退款</label>
						<div class="layui-input-block">
							<input type="text" id="if_refund" name="if_refund" value="{{ data.detail.IfRefund }}"
								lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
						</div>
					</div> -->



					<!-- <div class="layui-form-item">
						<label class="layui-form-label">LogisticsId</label>
						<div class="layui-input-block">
							<input type="text" id="logistics_id" name="logistics_id"
								value="{{ data.detail.LogisticsId }}" lay-verify="title" autocomplete="off"
								placeholder="" class="layui-input">
						</div>
					</div> -->

					<div class="layui-form-item layui-layout-admin">
						<div class="layui-input-block">
							<div class="layui-footer" style="left: 0;">
								<!-- <button class="layui-btn" lay-submit="" lay-filter="edit-submit">提交</button> -->
								<a href="javascript:goBack()" class="layui-btn layui-btn-primary">返回</a>
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>


	<script src="/public/layui/admin/layui/layui.js"></script>
	<script>
		layui.config({
			base: '/public/layui/admin/' //静态资源所在路径
		}).extend({
			index: 'lib/index' //主入口模块
		}).use(['index', 'table', 'form', 'laydate', 'jquery', 'upload'], function () {
			var $ = layui.$,
				admin = layui.admin,
				element = layui.element,
				layer = layui.layer,
				laydate = layui.laydate,
				form = layui.form;

			form.render(null, 'component-form-group');
			laydate.render({
				elem: '#LAY-component-form-group-date'
			});

			var orderDetails = {};

			var table = layui.table;
			table.render({
				elem: '#data-table',
				//url: '/admin/ProductSpec/GetProductSpecListJson?product_id={{data.detail.id}}&appid={{data.Who.MiniAppId}}&tid={{data.Who.TenantId}}',
				cellMinWidth: 80, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
				toolbar: '#data-table-filter',
				data: orderDetails,
				cols: [
					[
						//#TableJsonFields#
						{
							field: 'id',
							title: 'id',
							hide: true
						},
						{
							field: 'defaultImage',
							title: '图片',
							hide: false,
							templet: function (d) {
								if (d.DefaultImage) {
									return "<img src='" + d.DefaultImage + "' width='100px' />"
								}
							}
						},
						{
							field: 'spec_id',
							title: '商品',
							hide: false,
							templet: function (d) {
								return d.ProductName + d.SpecName
							}
						},
						{
							field: 'SellPrice',
							title: '价格',
							hide: false,
							templet: function (d) {
								return d.SellPrice / 100.00;
							}
						},
						{
							field: 'Num',
							title: '数量',
							hide: false
						},
						{
							field: 'Num',
							title: '总金额',
							hide: false,
							templet: function (d) {
								return d.SellPrice * d.Num / 100.00;
							}
						}
					]
				],
				page: false
			});

			/* 自定义验证规则 */
			form.verify({
				title: function (value) {
					if (value.length < 0) {
						return '请输入';
					}
				},
				pass: [/(.+){6,12}$/, '密码必须6到12位'],
				content: function (value) {
					layedit.sync(editIndex);
				}
			});

			// 文件上传
			var upload = layui.upload;
			upload.render({
				elem: '#upload-drag',
				url: '/admin/upload',
				done: function (res) {
					console.log(res)
					$("#img-upload").attr("src", res.data.imgurl);
					// TODO: $("#prdminipic").val(res.data.imgurl);
				}
			});

			// /* 监听提交 */
			// form.on('submit(edit-submit)', function (data) {
			// 	// parent.layer.alert(JSON.stringify(data.field), {
			// 	//   title: '最终的提交信息'
			// 	// })
			// 	$.ajax({
			// 		type: "POST",
			// 		url: "/admin/Orders/editpage",
			// 		data: data.field,
			// 		async: true,
			// 		error: function (request) {
			// 			parent.layer.alert(JSON.stringify(request), {
			// 				title: '操作失败'
			// 			});
			// 		},
			// 		success: function (response) {
			// 			console.log(response);
			// 			//var rt = JSON.parse(response);
			// 			var rt = response
			// 			if (rt.code == 0) {
			// 				var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
			// 				parent.layer.close(index);
			// 			} else {
			// 				parent.layer.alert(rt.msg, {
			// 					title: '操作失败'
			// 				});
			// 			}
			// 		}
			// 	});
			// 	return false;
			// });

			init();

			function init() {
				$.ajax({
					type: "Get",
					url: '/admin/Orders/getOrderDetail_saas?order_id={{data.detail.Id}}&appid={{data.Who.MiniAppId}}&tid={{data.Who.TenantId}}',
					async: true,
					error: function (request) {
						parent.layer.alert(JSON.stringify(request), {
							title: '操作失败'
						});
					},
					success: function (response) {
						orderDetails = response.data;

						table.reload('data-table', {
							data: orderDetails
						});

						// table.render({ //其它参数在此省略
						// 	height: 315 //固定值
						// });
					}
				});

			}

			/* 监听指定开关
        form.on('switch(component-form-switchTest)', function(data){
          layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
            offset: '6px'
          });
          layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });*/
		});

		// 页面返回上一页面
		function goBack() {
			var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
			parent.layer.close(index);
		};
	</script>
	<style>
		.layui-table-cell {
			height: auto !important;
			white-space: normal;
		}

		.status {
			font-size: 20px;
			font-weight: bold;
			color: red;
			margin-left: 30px;
		}
	</style>
</body>

</html>